import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.util.Scanner;

public class demo1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int year=scanner.nextInt();
        int month=scanner.nextInt()-1;
        int day=scanner.nextInt();
        int sum=0;
        switch (month) {
            case 12:sum+=31;
            case 11:sum+=30;
            case 10:sum+=31;
            case 9:sum+=30;
            case 8:sum+=31;
            case 7:sum+=31;
            case 6:sum+=30;
            case 5:sum+=31;
            case 4:sum+=30;
            case 3:sum+=31;
            case 2:sum+=28;
            case 1:sum+=31;
        }
        if(month>=2&&((year%100!=0&&year%4==0)||(year%400==0))) {
            sum+=1;
        }
        sum+=day;
        System.out.println(sum);
    }
}